<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@include file="/common/taglibs.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><fmt:message key='label.home.home.jsp.appname'/></title>
<%@include file="/common/scripts.jsp" %>
<style type="text/css">
<!--
    .style1 {
        color: #FFFFFF
    }
-->
</style>
<script language="javascript">
$(function(){
	<c:if test="${fn:length(param.error)>0}">
    alert("<fmt:message key='${param.error}'/>");
	</c:if>
	
	$("#loginBtn").click(function(){
        var login = document.getElementById("login").value = trim(document.getElementById("login").value);
        var password = document.getElementById("password").value = trim(document.getElementById("password").value);
        var msgs = "";
        if (login.length == 0){
            msgs = msgs + "<fmt:message key='dialog.message.param.isRequired'><fmt:param><fmt:message key='system.bo.SysUser.login'/></fmt:param></fmt:message>\n";
        }
        if (password.length == 0){
            msgs = msgs + "<fmt:message key='dialog.message.param.isRequired'><fmt:param><fmt:message key='system.bo.SysUser.password'/></fmt:param></fmt:message>\n";
        }

        if (msgs.length == 0){
            document.theForm.action = "j_spring_security_check";
            document.theForm.submit();
        } else {
            alert(msgs);
        }
	});
	
	$("#cleanBtn").click(function(){
        document.getElementById("login").value="";
        document.getElementById("password").value="";
        document.getElementById("sendTo").value="";
	});
	
	$("#mailBtn").click(function(){
        var sendTo = document.getElementById("sendTo").value = trim(document.getElementById("sendTo").value);
        if (sendTo.length == 0 ){
            alert("<fmt:message key='dialog.message.param.isRequired'><fmt:param><fmt:message key='system.bo.SysUser.login'/></fmt:param></fmt:message>");
        } else {
            $.post("<c:url value='login?pwd=sendMail'/>",{"login":sendTo},function(data){
            	alert(data.message);
            });
        }
	});	


	$("#table1").find("input").keypress(function(event){
        if (event.keyCode == 13){
	        $("#loginBtn").click();
	    }
	});
});
function changeTable(num)
{
if (num==1){
document.all("table1").style.display="";
document.all("table2").style.display="none";
}else if(num==2){
document.all("table1").style.display="none";
document.all("table2").style.display="";
}
}

function changeLocale(){
	 document.theForm.action = "login";
     document.theForm.submit();
}   

</script>
</head>
<body>
<form action="j_spring_security_check" name="theForm" method="post">
    <div class="loginOuter">
    	<div class="loginInputContainer">
        	<table width="96%" align="center" id ="table1" style="width:auto; margin-top:50px;">
              <tr>
                <td class="Txt_white"><span>帳號</span></td>
                <td><input type="text" name="j_username" id="login" class="required uppercase"/></td>
              </tr>
              <tr>
                <td class="Txt_white"><span>密碼</span></td>
                <td><input type="password" name="j_password" id="password" class="required" /></td>
              </tr>
              <tr>
                <td colspan="2" class="textAlignRight">                
                <a href="javascript:void(0);" id="loginBtn" class="css_btn" style="margin-top:5px;">登入</a>
                <a href="javascript:void(0);" id="cleanBtn" class="css_btn" style="margin-top:5px;">清除</a>
                </td>
              </tr>
          </table>
        </div>
    </div>
</form>
</body>
</html>
